import request from '@/utils/http'

// 后端服务监控模型对应的前端类型定义
export interface CpuInfo {
    cpu_num?: number
    used?: number
    sys?: number
    free?: number
}

export interface MemoryInfo {
    total?: string
    used?: string
    free?: string
    usage?: number
}

export interface SysInfo {
    computer_ip?: string
    computer_name?: string
    os_arch?: string
    os_name?: string
    user_dir?: string
}

export interface PyInfo extends MemoryInfo {
    name?: string
    version?: string
    start_time?: string
    run_time?: string
    home?: string
}

export interface SysFile {
    dir_name?: string
    sys_type_name?: string
    type_name?: string
    total?: string
    used?: string
    free?: string
    usage?: string
}

export interface ServerMonitorModel {
    cpu?: CpuInfo
    py?: PyInfo
    mem?: MemoryInfo
    sys?: SysInfo
    sys_files?: SysFile[]
}

/** 获取服务器监控数据 */
export function fetchServerMonitor() {
    return request.get<ServerMonitorModel>({ url: '/system/server/monitor' })
}